package com.eshop.enums;

import java.util.stream.Stream;

public enum OrderStatusEnum
{
    STATUS_0(Integer.valueOf(0), "未支付"), 
    STATUS_1(Integer.valueOf(1), "待发货"), 
    STATUS_2(Integer.valueOf(2), "待收货"), 
    STATUS_3(Integer.valueOf(3), "待评价"), 
    STATUS_4(Integer.valueOf(4), "已完成"), 
    STATUS_MINUS_1(Integer.valueOf(-1), "退款中"), 
    STATUS_MINUS_2(Integer.valueOf(-2), "已退款"), 
    STATUS_MINUS_3(Integer.valueOf(-3), "退款");
    
    private Integer value;
    private String desc;
    
    public static OrderStatusEnum toType(final int value) {
        return Stream.of(values()).filter(p -> p.value == value).findAny().orElse(null);
    }
    
    public Integer getValue() {
        return this.value;
    }
    
    public String getDesc() {
        return this.desc;
    }
    
    private OrderStatusEnum(final Integer value, final String desc) {
        this.value = value;
        this.desc = desc;
    }
}
